/*
    * Copyright (c) 2024 Hunan OpenValley Digital Industry Development Co., Ltd.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
 */

#ifndef FILE_SHARE_ERRORCODE_H
#define FILE_SHARE_ERRORCODE_H

#include <cstdint>
#include <file_share_log.h>

namespace OHOS {
namespace FileShare {
enum ErrorCode : int32_t {
    // General error code
    FS_SUCCESS = 0,
    FS_FAILURE = -1,

    // Common error code(1001~1099)
    FS_OUT_OF_MEMORY = 1001,
    FS_NULL_PARAM = 1002,
    FS_INVALID_PARAM = 1003,
    FS_URI_TO_PATH_FAILED = 1004,
    FS_HASH_FAILED = 1005,
    FS_STORAGE_GET_HAPINFO_INVALID = 1006,
    FS_STORAGE_URI_INVALID = 1007,
    FS_STORAGE_URI_GET_PATH_FAILED = 1008,
    FS_STORAGE_PATH_ACCESS_FAILED = 1009,

    // Proxy error code(1100~1199)
    FS_PROXY_SEND_REQUEST_FAILED = 1100,
    FS_GET_SA_MANAGER_FAILED = 1101,
    FS_GET_PROXY_FAILED = 1102,
    FS_NEW_DEATH_RECIPIENT_FAILED = 1103,
    FS_REGISTER_CALLBACK_FAILED = 1104,
    FS_GET_USER_ID_FAILED = 1105,
    FS_SET_STORAGE_PATH_ERROR = 1106,
    FS_GET_STORAGE_PATH_ERROR = 1107,
    FS_SET_WORK_DURATION_ERROR = 1108,
    FS_GET_WORK_DURATION_ERROR = 1109,

    // dsoftbus error code(1200~1299)
    FS_CREATE_SESSION_SERVER_FAILED = 1200,
    FS_REMOVE_SESSION_SERVER_FAILED = 1201,
    FS_INIT_DEV_MANAGER_FAILED = 1202,
    FS_GET_TRUST_DEVICE_INFO_FAILED = 1203,
    FS_OPEN_SESSION_TIME_OUT = 1204,
    FS_SEND_FILE_FAILED = 1205,
    FS_ABORT_RECV_FAILED = 1206,
    FS_SEND_MESSAGE_FAILED = 1207,
    FS_SET_BLE_UUID_LNN_FAILED = 1208,

    // queue error code(1300~1399)
    FS_QUEUE_STOPED = 1300,
    FS_QUEUE_EMPTY = 1301,
    FS_QUEUE_FULL = 1302,
};

#define CHKPTR(cond, r)                                                                     \
    do                                                                                      \
    {                                                                                       \
        if ((cond) == nullptr)                                                              \
        {                                                                                   \
            LOGE("CHKPTR(%{public}s) is null, return value is %{public}d", #cond, r); \
            return r;                                                                       \
        }                                                                                   \
    } while (0)

} // namespace FileShare
} // namespace OHOS
#endif // FILE_SHARE_ERRORCODE_H